package com.newsvoice.activity;

import com.newsvoice.gcm.PushNotificationRegister;
import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

public class MenuActivity extends TabActivity {

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.main);		
		Resources ressources = getResources();
		TabHost tabHost = getTabHost();

		// Android tab
		Intent intentAndroid = new Intent().setClass(this, MainActivity.class);
		TabSpec tabSpecAndroid = tabHost
				.newTabSpec("Topic News")
				.setIndicator("Topic News")
				
//				.setIndicator("",
//						ressources.getDrawable(R.drawable.ic_launcher))
				.setContent(intentAndroid);

		
		// Apple tab
		Intent intentApple = new Intent().setClass(this,
				RecommendNewsActivity.class);
		TabSpec tabSpecApple = tabHost
				.newTabSpec("Recommend News")
				.setIndicator("Recommend News")
//				.setIndicator("",
//						ressources.getDrawable(R.drawable.ic_launcher))
				.setContent(intentApple);

		// Windows tab
//		Intent intentWindows = new Intent().setClass(this,
//				SearchByTagActivity.class);
//		TabSpec tabSpecWindows = tabHost
//				.newTabSpec("Search By Tag")
//				.setIndicator("Search by tag")
////				.setIndicator("",
////						ressources.getDrawable(R.drawable.ic_launcher))
//				.setContent(intentWindows);

		// Blackberry tab
		Intent intentBerry = new Intent().setClass(this,
				PushNotificationRegister.class);
		TabSpec tabSpecBerry = tabHost
				.newTabSpec("Berry")
				.setIndicator("automatically news")
				.setContent(intentBerry);

		// add all tabs
		tabHost.addTab(tabSpecAndroid);
		tabHost.addTab(tabSpecApple);
//		tabHost.addTab(tabSpecWindows);
		tabHost.addTab(tabSpecBerry);

		// set Windows tab as default (zero based)
		tabHost.setCurrentTab(2);
		
		for(int i=0;i<tabHost.getTabWidget().getChildCount();i++) 
	    {
	        TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title);
//	        tv.setLinkTextColor(R.color.tab_text_color);
	    } 
	}

	// /** Called when the activity is first created. */
	// @Override
	// public void onCreate(Bundle savedInstanceState) {
	// super.onCreate(savedInstanceState);
	// setContentView(R.layout.menu);
	//
	// ListView menuList = (ListView) findViewById(R.id.ListView_Menu);
	//
	// String[] items = {
	// getResources().getString(R.string.menu_item_topic),
	// getResources().getString(R.string.menu_item_recommend),
	// getResources().getString(R.string.menu_item_search_by_tag),
	// getResources().getString(R.string.menu_item_register_push_notification)
	// };
	// ArrayAdapter<String> adapt = new ArrayAdapter<String>(this,
	// R.layout.menu_item, items);
	// menuList.setAdapter(adapt);
	//
	// menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
	//
	// public void onItemClick(AdapterView<?> parent, View itemClicked,
	// int position, long id) {
	//
	// // Note: if the list was built "by hand" the id could be used.
	// // As-is, though, each item has the same id
	//
	// TextView textView = (TextView) itemClicked;
	// String strText = textView.getText().toString();
	//
	// if (strText.equalsIgnoreCase(getResources().getString(
	// R.string.menu_item_topic))) {
	// // Launch the Game Activity
	// startActivity(new Intent(MenuActivity.this,
	// MainActivity.class));
	// } else if (strText.equalsIgnoreCase(getResources().getString(
	// R.string.menu_item_register_push_notification))) {
	// // Launch the Help Activity
	// startActivity(new Intent(MenuActivity.this,
	// PushNotificationRegister.class));
	// } else if (strText.equalsIgnoreCase(getResources().getString(
	// R.string.menu_item_search_by_tag))) {
	// startActivity(new Intent(MenuActivity.this,
	// SearchByTagActivity.class));
	// } else if (strText.equalsIgnoreCase(getResources().getString(
	// R.string.menu_item_recommend))) {
	// startActivity(new Intent(MenuActivity.this,
	// RecommendNewsActivity.class));
	// // Launch the Scores Activity
	// // startActivity(new Intent(MenuActivity.this,
	// // QuizScoresActivity.class));
	// }
	//
	// }
	// });
	//
	// }

}